using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;

namespace usm.SolDev.Common.Config
{
    [Serializable]
    public class CompilerConfig : Configuration
    {
        #region Private fields
        private string binaryDir = "\\compiler\\bin";
        private string compiler = "\\solcompiler.exe";
        private string switches = " -s -e ";
        private string includesDir = "\\compiler\\include";
        private string librariesDir = "\\compiler\\lib";
        private string projectName = "main";
        #endregion

        #region Constructors
        /// <summary>
        ///     default constructor
        /// </summary>
        public CompilerConfig () {}
        #endregion

        #region Public properties
        /// <summary>
        ///     Build full compiler command
        /// </summary>
        /// <returns>the full command required for compilation</returns>
        [XmlAttributeAttribute(DataType = "string")]
        public string CompileString
        {
            get
            {
                return String.Format("{0}{1} {2} -b \"{0}{3}\" -i \"{0}{4}\" -l \"{0}{5}\" ", ApplicationPath, compiler, switches, binaryDir, includesDir, librariesDir);
            }

            set { }
        }

        public string CompilerPath
        {
            get { return String.Format("{0}{1}", ApplicationPath, compiler); }
        }

        public string Arguments
        {
            get { return String.Format("{2} -b \"{0}{3}\" -i \"{0}{4}\" -l \"{0}{5}\" ", ApplicationPath, compiler, switches, binaryDir, includesDir, librariesDir); }
        }

        /// <summary>
        ///     The compiler location dir
        /// 
        ///     This property is available for serialization just to 
        /// exemplify the compiler options and result command format.
        /// </summary>
        [XmlAttributeAttribute(DataType = "string")]
        public string BinaryDir
        {
            get { return binaryDir; }
            set { binaryDir = value; }
        }

        /// <summary>
        ///     The complier command
        /// </summary>
        [XmlAttributeAttribute(DataType = "string")]
        public string Compiler
        {
            get { return compiler; }
            set { compiler = value; }
        }

        /// <summary>
        ///     Switches required for compilation
        /// </summary>
        [XmlAttributeAttribute(DataType = "string")]
        public string Switches
        {
            get { return switches; }
            set { switches = value; }
        }

        /// <summary>
        ///     The includes folder
        /// </summary>
        [XmlAttributeAttribute(DataType = "string")]
        public string IncludesDir
        {
            get { return includesDir; }
            set { includesDir = value; }
        }

        /// <summary>
        ///     The libraries folder
        /// </summary>
        [XmlAttributeAttribute(DataType = "string")]
        public string LibrariesDir
        {
            get { return librariesDir; }
            set { librariesDir = value; }
        }

        /// <summary>
        ///     Source file name
        /// </summary>
        [XmlIgnore]
        public string ProjectName
        {
            get { return projectName; }
            set { projectName = value; }
        }
        #endregion
    }
}
